package logic

import (
	"context"
	"zhihu/mobels/mysql"

	"zhihu/zhihurpc/internal/svc"
	"zhihu/zhihurpc/zhihurpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListAnswerLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListAnswerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAnswerLogic {
	return &ListAnswerLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListAnswerLogic) ListAnswer(in *zhihurpc.ListAnswerRequest) (*zhihurpc.ListAnswerResponse, error) {
	// todo: add your logic here and delete this line
	var aswer []mysql.Answer
	var aswerList []*zhihurpc.ListAnswer

	for _, m := range aswer {
		list := zhihurpc.ListAnswer{
			UserId:       m.UserId,
			ProblemId:    m.ProblemId,
			Content:      m.Content,
			NickName:     m.User.NickName,
			HeaderImages: m.User.HeaderImage,
		}
		aswerList = append(aswerList, &list)
	}
	return &zhihurpc.ListAnswerResponse{List: aswerList}, nil
}
